hysop.backend.device.opencl.operator.derivative module

class hysop.backend.device.opencl.operator.derivative.OpenClFiniteDifferencesSpaceDerivative(**kwds)[source]

Bases: FiniteDifferencesSpaceDerivativeBase, OpenClSymbolic

SpaceDerivative operator base.

Compute the derivative of a field in a given direction on a given backend, possibly scaled by another field/parameter/value.

dF = A * dF/dxj

Parameters:
  • F (hysop.field.continuous_field.ScalarField) – Continuous field as input.

  • dF (hysop.field.continuous_field.ScalarField) – Continuous field to be written. Some backend may allow inplace differentiation.

  • A (numerical value, ScalarParameter or ScalarField, optional) – Scaling for convenience, defaults to 1.

  • derivative (int or tuple, optional) – Which derivative to generate, defaults to (0,)*(dim-1)+(1,). ie. first order derivative in X axis. If integer is given, the derivative is taken in given direction.

  • direction (int, optional) – Directions in which to take the derivative. Defaults to None. Should be None if derivative is a tuple.

  • require_tmp (bool, optional) – Should this operator generate a tmp array ? Default to True if F is dF (inplace computation) else False.

  • variables (dict) – Dictionary of fields as keys and topology descriptors as values.

  • name (str, optional) – Name of this operator

  • pretty_name (str, optional) – Pretty name of this operator.

  • kwds (dict, optional) – Base class keyword arguments.

Notes

There is two way to build a derivative:
  1. derivative(int) + direction(int) gives:
    => derivative=(0,0,0,0,kd,0,0,0)

    where the index of kd is direction and kd=derivative

  2. derivative(tuple) + direction(None) gives:

    => derivative=(k0,…,kn)

apply(**kwds)

Abstract method that should be implemented. Applies this node (operator, computational graph operator…).

setup(work)[source]

Setup temporary buffer that have been requested in get_work_properties(). This function may be used to execute post allocation routines. This sets self.ready flag to True. Once this flag is set one may call ComputationalGraphNode.apply() and ComputationalGraphNode.finalize().

Automatically honour temporary field memory requests.

class hysop.backend.device.opencl.operator.derivative.OpenClSpectralSpaceDerivative(**kwds)[source]

Bases: SpectralSpaceDerivativeBase, OpenClSymbolic

Compute a derivative of a scalar field in a given direction using spectral methods.

Initialize a SpectralSpaceDerivative operator on the opencl backend.

See hysop.operator.base.derivative.SpectralSpaceDerivativeBase for more information.

Parameters:

kwds (dict, optional) – Base class arguments.

apply(**kwds)

Abstract method that should be implemented. Applies this node (operator, computational graph operator…).

discretize(**kwds)[source]

Discretize symbolic expressions.

setup(work)[source]

Setup temporary buffer that have been requested in get_work_properties(). This function may be used to execute post allocation routines. This sets self.ready flag to True. Once this flag is set one may call ComputationalGraphNode.apply() and ComputationalGraphNode.finalize().

Automatically honour temporary field memory requests.